﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using AutoMapper;

namespace Data
{
   public class ThamSoRepository
    {
       private static ThamSoDTO MapThamSoEFToThamSoDTO(THAMSO thamsoEF)
       {
           Mapper.CreateMap<THAMSO, ThamSoDTO>();
           return Mapper.Map<THAMSO, ThamSoDTO>(thamsoEF);
       }
       public static ThamSoDTO GetThamSoByID(int mathamso)
       {
           ThamSoDTO kq = new ThamSoDTO();
           using (QuanLyNhaSachEntities context = new QuanLyNhaSachEntities())
           {
               try
               {
                   THAMSO query = (from thamso in context.THAMSOList
                               where thamso.MaThamSo == mathamso
                               select thamso).First();
                   kq = MapThamSoEFToThamSoDTO(query);

                   

               }
               catch
               {

               }
           }
           return kq;
       }
    }
}
